{% include 'JDXJ/JDXJ_index.html' %}

<div class="am-cf admin-main">
  {% include 'sidebar.html' %}
  <!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">日常巡查</strong></div>
      </div>
      <div class="am-g" style="position: absolute;height: 100%;right: 0px;left: 260px;width: auto;">

       {% include 'JDXJ/RCXC/JDXJ_RCXC_SIDEBAR.html' %}
        
        <div class="am-u-sm-10" style="position: absolute;width:auto;right:0;left: 200px;overflow-y: scroll;bottom: 200px;top: 0;">
          <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
              <div class="am-btn-group am-btn-group-xs">
<!--                 <button style="margin: 0 5px"  type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="back_to()">返回</button> -->
                <button style="margin: 0 5px"  type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="see_add()"><span class="am-icon-plus"></span>新增</button>
              </div>
            </div>
          </div>

          <table id="grid" class="am-table am-table-striped am-table-hover table-main am-table-compact " style="width: 100%">
            <thead>
              <tr>
                <th class="table-title">任务编号</th>
                <th class="table-title">系统</th>
                <th class="table-title">作业完成时间</th>
                <th class="table-title">作业人</th>
                <th class="table-title">设备名称</th>
                <th class="table-title">检查项目</th>
                <th class="table-title">检查内容</th>
                <th class="table-title">作业备注</th>
                <th class="table-title">操作</th>
              </tr>
            </thead>
            <tbody></tbody>
          </table>

        </div>
      </div>
    </div>
  </div>
</div>
{% include 'footer.html' %}
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/static/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/static/assets/js/amazeui.min.js"></script>
<script src="/static/assets/js/amazeui.tree.js"></script>
<script type="text/javascript" src="/static/assets/js//layer.js"></script>
<script src="/static/assets/datatables/amazeui.datatables.min.js"></script>
<script src="/static/assets/dialog/amazeui.dialog.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/assets/css/amazeui.tree.css" />
<script src="/static/assets/js/app.js"></script>
<style type="text/css">
  .li_a {
    color: #5c5c5c;
  }
</style>
<script type="text/javascript">
  $("#collapse-nav8").addClass("am-in");
  $("#jdxj").removeClass("am-collapsed");
  $("#jdxj").css("color", "#3399CC");
  $("#jdxjrcxc").css("color", "#3399CC");
  $("#rcwhjl").css("color", "#3399CC");
  $("#jdxjrcxc").removeClass("li_a");
  


  // var bridge_id = {{ bridge_id|safe }};
  // var check_id = {{ check_id|safe }};
  // var tp = {{ type|safe }};
  // if(tp == "1"){
  //   $("#xjywOdqjc").removeClass("li_a");
  // }else if(tp == "2"){
  //   $("#xjywOjcjc").removeClass("li_a");
  // // }
  // function back_to(){
  //   window.history.back(-1);
  // }

var t = $('#grid').DataTable({
  //配置DataTables默认参数



    bInfo: true,//页脚信息
    responsive: true,
    searching: true,
    lengthChange: false,
    paging: true,
    bStateSave: true, //保存页面状态
    aLengthMenu: [[10], [10]],
    ajax: {
      url: "/JDXJ_RCXC_WHJL_DATA/"
    },


    
    //每页显示五条数据
    //pageLength: 'all',
    columns: [    
      {
        "data": "record_code"
      },
      {
        "data": "sys_name"
      },

      {
        "data": "done_date"
      },
      {
        "data": "done_person"
      },
      {
        "data": "device_name"
      },
      {
        "data": "check_pro"
      },
      {
        "data": "check_content"
      },
      {
        "data": "remark"
      },
      {
        "data": "remark"
      }
    ],
    
    
    "columnDefs": [
      // "visible": false,
      //"targets": 0



      {
        type: 'chinese-string',
        targets: '_all'
      } //中文排序
      ,   
      
      {
        "render": function(data, type, row, meta) {
          return '<div class="am-btn-toolbar"><div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="see_modify(' + row.record_id + ')"><span class="am-icon-pencil-square-o"></span> 修改</button><button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="see_delect(' + row.record_id + ',\'' + row.record_code + '\')"><span class="am-icon-trash-o"></span> 删除</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="see_img(' + row.record_id + ')"><span class="am-icon-pencil-square-o"></span> 媒体信息</button></div></div>'
                  
        },
        //指定是第二列
        "targets": 8
      }
    ],
    

  });

  //新增
  function see_add(){
    window.location.href="/JDXJ_RCXC_WHJL_ADD/"
    // popup("新增定期检查","/QLXJ_XJYW_DQJC_add/")
  }

  //修改
  function see_modify(record_id){
    window.location.href="/JDXJ_RCXC_WHJL_MOD/?record_id="+record_id+""
  }

  // //移动
  // function see_move(check_record_id){
  //   // window.location.href="/QLXJ_XJYW_DQJC_DISEASE_MOVE/?check_record_id="+check_record_id+""
  //   popup("移动","/QLXJ_XJYW_DQJC_DISEASE_MOVE/?check_record_id="+check_record_id+"")
  // }




  //媒体信息
  function see_img(check_record_id){
    $.ajax({
      "url":"/JDXJ_RCXC_WHJL_MEDIA/?record_id="+check_record_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
    }).success(function(data){
      if (data.status == 1) {
        // window.location.reload();
        var data_new = [];
        // console.log(data)
        for(var i=0;i<data.data.length;i++){
          var list = {"pid": "","thumb": ""};
          list["alt"] = data.data[i].file_name;
          list["src"] = data.data[i].file_url;
          data_new.push(list);

        };
        var  json ={
          "title": "", //相册标题
          "id": "", //相册id
          "start": 0, //初始显示的图片序号，默认0
          "data": data_new
        };
        // var  aaa ={
        //   "title": "", //相册标题
        //   "id": "", //相册id
        //   "start": 0, //初始显示的图片序号，默认0
        //   "data": [   //相册包含的图片，数组格式
        //     {
        //       "alt": "图片名",
        //       "pid": 666, //图片id
        //       "src": "http://s.amazeui.org/media/i/demos/pure-4.jpg", //原图地址
        //       "thumb": "" //缩略图地址
        //     },{
        //       "alt": "图片名",
        //       "pid": 666, //图片id
        //       "src": "http://s.amazeui.org/media/i/demos/pure-4.jpg", //原图地址
        //       "thumb": "" //缩略图地址
        //     }
        //   ]
        // }
        layer.photos({
          photos: json, //格式见API文档手册页
          anim: 5 ,//0-6的选择，指定弹出图片动画类型，默认随机
          area: ['800px', 'auto']
        });
      } else {
        AlertMSG(data.message)
      }
    }).error(function(data){
      AlertMSG("读取媒体信息失败！")
    });
  

    // window.location.href="/QLXJ_XJYW_DQJC_DISEASE_ADD/?check_id="+check_id+"&bridge_id="+bridge_id+""
    // popup("媒体信息","/QLXJ_XJYW_DQJC_add/")
  }


  //删除
  function see_delect(check_record_id,name){
    AMUI.dialog.confirm({
      title: '删除确认',
      content: '您确认删除编号为：['+name+']的病害信息?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
      "url":"/JDXJ_RCXC_WHJL_DEL/?record_id="+check_record_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          window.location.reload();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("删除失败！")
      });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };


  function popup(title,url){
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
            area: ['600px', '380px'],
            
        });

        
        //铺满界面
        //layer.full(index);
  }
  var AlertMSG=function(msg){
    AMUI.dialog.alert({ title: '错误提示', content: msg, onConfirm: function() { console.log('close'); } });
  }

</script>
 
</body>

</html>